home *** CD-ROM | disk | FTP | other *** search
- /*
- ** CTCPSessionDoc.h
- **
- ** TurboTCP support library
- ** TCP session document
- **
- ** Copyright © 1993, FrostByte Design / Eric Scouten
- **
- */
-
-
- #pragma once
-
- #ifndef TurboTCPHeaders
- #include <CDocument.h>
- #include <MacTCPCommonTypes.h>
- #endif
-
- CLASS CTCPStream;
- CLASS CTCPResolverCall;
-
-
- /*______________________________________________________________________
- **
- ** CTCPSessionDoc
- **
- ** This abstract class is provided to link the TCL CDocument class with the TurboTCP
- ** CTCPStream class. View this as a “connection session” document; this is the point at
- ** which the user interaction with the TCP session is handled.
- **
- ** This class provides all of the necessary behaviors for opening and closing a session.
- ** It provides abstract methods for receiving data and handling various TCP notifications.
- ** By default, it sets the window title to the name of the remote host. You may also
- ** configure it to show the document’s filename, both hostname & filename, or neither.
- ** (See the fields showFileName and showHostName and the method AutoTitle.
- **
- ** This class does not implement any specific TCP protocol. You will need to subclass it
- ** to provide the behaviors specific to the protocol you are implementing. You may want
- ** to examine and use the CTelnetInterpreter class to see how this may be done.
- **
- ** NOTE: This class is provided only as a convenience. You need not include it in your project.
- **
- */
-
-
- class CTCPSessionDoc : public CDocument {
-
- // informational fields — don’t change these
-
- public:
- CTCPStream *itsStream; // TCP stream for this document
- CTCPResolverCall *itsResolver; // TCP resolver for this document
- protected:
- Boolean pendingOpenByName; // OpenUserHost has been issued
- b_16 pendingPortNumber; // port number for OpenUserHost
- Boolean closeAndQuit; // closing windows to quit
- Boolean sessionReady; // connection is open; can accept data
-
- char hostCName [256]; // canonical name of host
- // if cnames not requested, is user’s name
- ip_addr hostAddress; // IP address of host
- b_16 defaultPort; // default port number
- b_16 actualPort; // current port number
-
- // configuration fields — your subclass may change these variables
-
- Boolean useCName; // get host’s canonical name
- Boolean goAwayOnClose; // close window when session closes
- Boolean showFileName; // show filename in window titles
- Boolean showHostName; // show host name in window titles
- short untitledNumber; // serial number for untitled document
-
-
- // construction/destruction
-
- public:
- void ITCPSessionDoc (CApplication *aSupervisor, Boolean printable, long rcvBufferSize,
- b_16 theDefaultPort, Boolean doUseCName, short autoReceiveSize,
- short autoReceiveNum);
- virtual void Dispose (void);
-
-
- // opening/closing session
-
- virtual void OpenUserHost (char *theHostName, b_16 theDefaultPort, Boolean allowPortChange);
- virtual Boolean Close (Boolean quitting);
-
-
- // document/window naming
-
- virtual void AutoTitle (void);
- virtual void GetName (Str255 theName);
- virtual Boolean SessionEstablished (void);
-
-
- // special error handling
-
- virtual short TCPErrorAlert (OSErr err, long message, short alertID, short parm3);
-
-
- // TCP/DNR notification routines
-
- virtual void ProviderChanged (CCollaborator *aProvider, long reason, void *info);
- protected:
- virtual void HandleClosed (void);
- virtual void HandleClosing (Boolean remoteClosing);
- virtual void HandleDataArrived (Ptr theData, b_16 theDataSize, Boolean isUrgent);
- virtual void HandleDataSent (wdsEntry *WDSPtr);
- virtual void HandleICMP (struct ICMPReport *icmpMsg);
- virtual void HandleOpened (void);
- virtual void HandleOpenFailed (OSErr theResultCode);
- virtual void HandleSendFailed (wdsEntry *WDSPtr, OSErr theResultCode);
- virtual void HandleTCPError (OSErr theResultCode, short theCsCode);
- virtual void HandleTerminated (b_16 terminReason, Boolean aboutToDispose);
- virtual void HandleTimeout (void);
- virtual void HandleUnexpectedData (void);
- virtual void HandleUrgentBegin (void);
-
- virtual void HandleStrToAddr (struct hostInfo *theHostInfo);
- virtual void HandleAddrToName (struct hostInfo *theHostInfo);
- virtual void HandleHInfo (struct returnRec *theHInfo);
- virtual void HandleMXInfo (struct returnRec *theMXInfo);
-
- };